
<template>
  <div v-for="(item,i) in store.state.duanzilist" class="items">
    <div>
      时间：{{ item.passtime }}
      <h4>{{ item.name }}</h4>
    </div>
    <div>{{ item.text }}</div>
    <hr />
  </div>
</template>

<script>

import store from './store/index'; // 全局状态管理
import axios from 'axios'


export default {
  name: 'App',
  provide: {
    store,
  },
  setup() {
    // 段子api
    const api = 'https://api.apiopen.top/getJoke?page=1&count=5&type=text';

    // fetch(api).then((res) => res.json()).then(result => { store.setDZlist(result.result) });

    axios.get(api).then((result) => { store.setDZlist(result.data.result) });

    return {
      store
    }
  }
}
</script>
<style lang="" scoped>
  .items{
    text-align: left;
  }
  h4{
    display: inline-block;
    margin-left: 20px;
  }
</style>